/*
* berton
*/
package com.pitop.repair.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

import com.pitop.repair.api.RepairStaffFeignApi;
import com.pitop.core.exceptions.RepairStaffException;
import com.pitop.core.exceptions.BaseException;
import com.pitop.core.entity.Page;
import com.pitop.repair.entity.RepairStaff;


/**
 * 维修账户
 * @author berton
 */
@Service("repairStaffSVImpl")
@Slf4j
public class RepairStaffSVImpl {

    @Autowired
    private RepairStaffFeignApi repairStaffFeignApi;

    /**
     * 加载一个对象RepairStaff
     * @param id * @param code 编码
     * @return RepairStaff
     */
    public RepairStaff load(java.lang.Long id,java.lang.String code) {
        if(id==null&&code==null){
            throw new RepairStaffException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        return repairStaffFeignApi.load(id,code);
    }
    /**
     * 加载一个对象RepairStaff 通过id
     * @param id 
     * @return RepairStaff
     */
    public RepairStaff loadById(java.lang.Long id) {
        if(id==null){
            throw new RepairStaffException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        return repairStaffFeignApi.loadById(id);
    }

    /**
     * 加载一个对象RepairStaff 通过code
     * @param code 编码
     * @return RepairStaff
     */
    public RepairStaff loadByCode(java.lang.String code) {
        if(code==null){
            throw new RepairStaffException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        return repairStaffFeignApi.loadByCode(code);
    }


    /**
     * 删除对象RepairStaff
     * @param id * @param code 编码
     * @return RepairStaff
     */
    
    public void delete(java.lang.Long id,java.lang.String code) {
        if(id==null&&code==null){
            throw new RepairStaffException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        repairStaffFeignApi.delete(id,code);
    }



    /**
     * 查询RepairStaff分页
     *
     * @param repairStaff  对象
     * @param curPage 当前页
     * @param pageSize 分页条数
     * @return List<RepairStaff>
     */
    public List<RepairStaff> list(RepairStaff repairStaff, int curPage,int pageSize) {
        return repairStaffFeignApi.list(repairStaff, curPage,pageSize);
    }

    /**
     * 查询RepairStaff分页
     *
     * @param id  * @param code  编码
     * @param curPage 当前页
     * @param pageSize 分页条数
     * @return List<RepairStaff>
     */
    public List<RepairStaff> list(java.lang.Long id,java.lang.String code,int curPage, int pageSize) {
        if (curPage < 0) {
           curPage = 1;
        }

        if (pageSize < 0) {
            pageSize = Page.limit;
        }

        RepairStaff repairStaff=new RepairStaff();
        repairStaff.setId(id);
        repairStaff.setCode(code);

        return repairStaffFeignApi.list(repairStaff,curPage,pageSize);
    }


    public int count(java.lang.Long id,java.lang.String code) {
        return repairStaffFeignApi.count(id,code);
    }


    public int count(RepairStaff repairStaff) {
        return repairStaffFeignApi.count(repairStaff);
    }


    /**
     * 保存
     *
     * @param repairStaff 实体
     * @throws BaseException
     */
    public void save(RepairStaff repairStaff) {
        if(repairStaff==null){ throw new RepairStaffException(BaseException.BaseExceptionEnum.Ilegal_Param);}
        repairStaffFeignApi.build(repairStaff);
    }

    /**
     * 更新
     *
     * @param repairStaff 实体
     * @throws BaseException
     */
    public void modify(RepairStaff repairStaff) {
        if(repairStaff==null){ throw new RepairStaffException(BaseException.BaseExceptionEnum.Ilegal_Param);}
        repairStaffFeignApi.modify(repairStaff);
    }

}
